package com.emm.yixun.mobile.adapter;

import java.util.ArrayList;

import com.emm.yixun.mobile.model.GetWorkloadStatisticsList.WorkloadStatisticsList;

import android.app.Activity;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.emm.yixun.mobile.R;

/** 工作量统计分析 */
public class Analysis_work_adapter extends BaseAdapter {

	Activity a;
	ArrayList<WorkloadStatisticsList> list;

	public Analysis_work_adapter(Activity a, ArrayList<WorkloadStatisticsList> list) {
		this.a = a;
		this.list = list;
	}

	public void SetDate(ArrayList<WorkloadStatisticsList> list) {
		this.list = list;
		notifyDataSetChanged();
	}

	public void ClearDetails() {
		if (null != this.list) {
			this.list.clear();
		} else {
			this.list = new ArrayList<WorkloadStatisticsList>();
		}
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return list == null ? 0 : list.size();
	}

	@Override
	public Object getItem(int position) {
		return list == null ? null : list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHoudler v = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(a).inflate(R.layout.analysis_item, null);
			v = new ViewHoudler();
			v.type_content = (TextView) convertView.findViewById(R.id.type_content);
			v.v_followup = (TextView) convertView.findViewById(R.id.v_followup);
			v.v_newcustmoet = (TextView) convertView.findViewById(R.id.v_newcustmoet);
			v.v_qianyue = (TextView) convertView.findViewById(R.id.v_qianyue);
			v.v_rencou = (TextView) convertView.findViewById(R.id.v_rencou);
			v.v_rengou = (TextView) convertView.findViewById(R.id.v_rengou);
			v.bg_analysis = (LinearLayout) convertView.findViewById(R.id.bg_analysis);
			convertView.setTag(v);
		} else {
			v = (ViewHoudler) convertView.getTag();
		}
		if (position % 2 == 0) {
			v.bg_analysis.setBackgroundColor(Color.parseColor("#FFF5E9"));//#EAF0F0
		} else {
			v.bg_analysis.setBackgroundColor(Color.parseColor("#ffffff"));
		}

		v.type_content.setText(list.get(position).getUserName());
		v.v_followup.setText(list.get(position).getFollowNum());
		v.v_newcustmoet.setText(list.get(position).getAddCustomerNum());
		v.v_qianyue.setText(list.get(position).getSignedNum());
		v.v_rencou.setText(list.get(position).getPayDepositNum());
		v.v_rengou.setText(list.get(position).getSubscribeNum());
		return convertView;
	}

	public static class ViewHoudler {
		TextView type_content;// 姓名
		TextView v_followup;// 跟进数
		TextView v_newcustmoet;// 新增客户数
		TextView v_rencou;// 认筹数
		TextView v_rengou;// 认购数
		TextView v_qianyue;// 签约数
		LinearLayout bg_analysis;
	}

}
